<{include file ="header.tpl"}>
<{include file ="navibar.tpl"}>
<{include file ="sidebar.tpl"}>
<!-- START 以上内容不需更改，保证该TPL页内的标签匹配即可 -->
<{$osadmin_action_alert}>
<{$osadmin_quick_note}>

<div class="well">
    <ul class="nav nav-tabs">
        <li class="active"><a href="#home" data-toggle="tab">添加统计代码</a></li>
    </ul>

    <div id="myTabContent" class="tab-content">
        <div class="tab-pane active in" id="home">

            <form id="tab" method="post" action="">
                <label>在线统计代码1</label>
                <textarea name="code1" id="code1" rows="5" cols="60" class="input-xlarge"><{$_POST.code1}></textarea>

                <label>在线统计代码2</label>
                <textarea name="code2" id="code2" rows="5" cols="60" class="input-xlarge"><{$_POST.code2}></textarea>

                <label>在线统计代码3</label>
                <textarea name="code3" id="code3" rows="5" cols="60" class="input-xlarge"><{$_POST.code3}></textarea>

                <div class="btn-toolbar">
                    <button type="button" class="btn btn-primary" onclick="tijiao()"><strong>提交</strong></button>
                </div>
            </form>
        </div>
    </div>
</div>


<script>
    function htmlEncodeByRegExp(str) {
        var s = "";
        if (str.length == 0) return "";
        s = str.replace(/&/g, "&amp;");
        s = s.replace(/</g, "&lt;");
        s = s.replace(/>/g, "&gt;");
        s = s.replace(/ /g, "&nbsp;");
        s = s.replace(/\'/g, "&#39;");
        s = s.replace(/\"/g, "&quot;");
        return s;
    }


    function tijiao() {
        var c1, c2, c3;
        if ($("#code1").val()) {
            c1 = htmlEncodeByRegExp($("#code1").val());
        } else {
            c1 = '';
        }

        if ($("#code2").val()) {
            c2 = htmlEncodeByRegExp($("#code2").val());
        } else {
            c2 = '';
        }
        if ($("#code3").val()) {
            c3 = htmlEncodeByRegExp($("#code3").val());
        } else {
            c3 = '';
        }
        $.ajax({
            url: 'tongji_edit.php',// 跳转到 action
            data: {
                "code1": c1,
                "code2": c2,
                "code3": c3
            },
            type: 'post',
            cache: false,
            dataType: 'json',
            success: function (data) {
                if (data.msg == "true") {
                    alert("提交成功");
                    window.location.reload();
                } else {
                    alert("服務器錯誤");
                    return;
                }
            },
            error: function () {
                alert("服務器錯誤！");
            }
        });
    }
</script>
<!-- END 以下内容不需更改，请保证该TPL页内的标签匹配即可 -->
<{include file="footer.tpl" }>